import request from "@/utils/request";
import type { ProxyTransformDTO, ProxyTransformSaveCmd, PageDTO, R } from "@/types";
import { ProxyTransformPageQry } from "@/types";

function getPage(qry: ProxyTransformPageQry): Promise<R<PageDTO<ProxyTransformDTO>>> {
  return request.get("/api/proxy-transform/page", { params: qry });
}

function getById(id: string): Promise<R<ProxyTransformDTO>> {
  return request.get("/api/proxy-transform/get-by-id", { params: { id } });
}

function save(cmd: ProxyTransformSaveCmd): Promise<R<string>> {
  return request.post("/api/proxy-transform/save", cmd);
}

function deleteById(id: string): Promise<R<string>> {
  return request.post("/api/proxy-transform/delete", { params: { id } });
}

function start(id: string): Promise<R<string>> {
  return request.post("/api/proxy-transform/start", {}, { params: { id } });
}

function stop(id: string): Promise<R<string>> {
  return request.post("/api/proxy-transform/stop",{}, { params: { id } });
}

export default {
  getPage,
  getById,
  save,
  deleteById,
  start,
  stop
};
